# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: Andreas 'Segaja' Schleifer <archlinux at segaja dot de>

pkgname=alicloud-vault
pkgver=1.3.4
pkgrel=2
pkgdesc='Vault for securely storing and accessing Alibaba Cloud credentials in development environments'
url='https://github.com/arafato/alicloud-vault'
arch=('loong64' 'x86_64')
license=('MIT')
depends=('glibc')
makedepends=('go')
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('d2a052c981f6c7322c323ad8b7313aa4da5f1b99b4391ce9ae1e8c1f93cb11ba86a3a0ab14cb9564d11c2a810252a986e1d32fdba8adf1438e71cfc85e05b13a')
b2sums=('04bebc0507565494832e507c02a7d04af0052d23997dae94f2dee636841b4bdd414726b7799e7ebc125e74857bb84fd24a68b087e539999a4aaebe32f13a51e3')

build() {
  cd ${pkgname}-${pkgver}
  export GO11MODULE=on
  export CGO_LDFLAGS="${LDFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath"
  go build -v \
    -ldflags "-linkmode=external -extldflags '${LDFLAGS}' -X main.Version=${pkgver}" .
}

check() {
  cd ${pkgname}-${pkgver}
  go test ./...
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 ${pkgname} -t "${pkgdir}/usr/bin"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 "${pkgname}.zsh" "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"
}

# vim: ts=2 sw=2 et:
